import request from "@/api/apiConfig";



// 获取首页数据
export async function getIndexData(data?: any) {
  return request<API.List<any>>({
    url: "/consumer/home/list",
    method: "GET",
    params: data,
  });
}

// 获取渠道卡券
export async function getChannelCard(data?: any) {
  return request<API.List<any>>({
    url: "/consumer/home/getCardIntegral",
    method: "GET",
    params: data,
  });
}

// 缓存渠道id
export async function setChannelId(data?: any) {
  return request<API.List<any>>({
    url: "/consumer/home/cacheChannelId",
    method: "GET",
    params: data,
  });
}

// 根据渠道id获取首页数据
export async function getIndexDataByChannelId(data?: any) {
  return request<API.List<any>>({
    url: "/consumer/home/getCategories",
    method: "GET",
    params: data,
  });
}

// 卡密激活
export async function activeCard(data?: any) {
  return request<API.List<any>>({
    url: "/consumer/customer/activateCard",
    method: "POST",
    data,
  });
}

// 获取公告详情
export async function getNoticeDetail(data: { noticeId: string | number }) {
  return request<any>({
    url: "/consumer/home/noticeDetail",
    method: "GET",
    params: data,
  });
}

// 获取用户协议
export async function getUserAgreement(data:any) {
  return request<any>({
    url: "/wechat/dict/data/getData",
    method: "GET",
    params: data,
  });
}

// 解密数据
export async function getDecrypt(data:any) {
  return request<any>({
    url: "/wechat/sms/decrypt",
    method: "POST",
    data,
  });
}


// 根据订单和金额区域预支付信息
export async function getPrePay(data:any) {
  return request<any>({
    url: "/consumer/consumerOrder/getPrePayInfo",
    method: "POST",
    data,
  });
}

// 结算
export async function settlement(data:any) {
  return request<any>({
    url: "/consumer/consumerOrder/getOrderAmount",
    method: "POST",
    data,
  });
}

// 结算支付
export async function settlementPay(data:any) {
  return request<any>({
    url: "/consumer/consumerOrder/creatPrePayOrder",
    method: "POST",
    data,
  });
}

// 使用记录
export async function getUseRecord(data:any) {
  return request<any>({
    url: "/consumer/consumerOrder/page",
    method: "GET",
    params: data,
  });
}

// 根据微信code获取用户信息
export async function getUserInfoByWxCode(data: { code: string }) {
  return request<any>({
    url: "/consumer/mp/userInfo",
    method: "GET",
    params: data,
  });
}

// 根据openid 验证是否激活
export async function checkUserIsActive(data: { openId: string }) {
  return request<any>({
    url: "/consumer/consumerUser/getOpenIdValidate",
    method: "POST",
    data
  });
}

// 创建用户
export async function createUser(data: {
  userHeadImage: string;
  verifyCode:string;
  nickName: string;
  openId: string;
  phoneNumber:string;
}) {
  return request<any>({
    url: "consumer/consumerUser/createCustomer",
    method: "POST",
    data,
  });
}

// 其它激活
export async function activeUser(data:any) {
  return request<any>({
    url: "/consumer/consumerUser/validatePay",
    method: "POST",
    data,
  });
}

// 卡密激活
export async function activeCardPwdUser(data:any) {
  return request<any>({
    url: "/consumer/consumerUser/activateCardRegister",
    method: "POST",
    data,
  });
}

// 领取积分或抵扣金
export async function receivePoints(data:any) {
  return request<any>({
    url: "/consumer/consumerUser/activateUser",
    method: "POST",
    data,
  });
}

// 获取抵扣金详情
export async function getDiscountList(data:any) {
  return request<any>({
    url: "/wechat/pointReceiveRecord/getCustomerDeducts",
    method: "GET",
    params: data,
  });
}

// 获取卡券领取详情
export async function getPointsList(data:any) {
  return request<any>({
    url: "/consumer/consumerRecord/page",
    method: "GET",
    params: data,
  });
}

// 卡券消费记录
export async function getCouponList(data:any) {
  return request<any>({
    url: "/wechat/payDetail/consumePage",
    method: "GET",
    params: data,
  });
}



// 获取订单详情
export async function getOrderDetail(data:any) {
  return request<any>({
    url: "/consumer/consumerOrder/getDetail",
    method: "GET",
    params: data,
  });
}

// 获取用户信息
export async function getUserInfo() {
  return request<any>({
    url: "/consumer/consumerUser/shortInfo",
    method: "GET",
  });
}

// 同步能量值
export async function getSyncEnergy() {
  return request<any>({
    url: "/consumer/consumerUser/syncEnergy",
    method: "GET",
  });
}

// 上传用户头像
export async function uploadUserHeadImage(data: any) {
  return request<any>({
    url: "/consumer/consumerUser/updateUserHeadImage",
    method: "POST",
    data,
  });
}

export async function records(data: { current: number; pageSize: number }) {
  return request<API.List<any>>({
    url: "/api/examples/records",
    method: "POST",
    data,
  });
}

export async function friends(data: {
  current: number;
  pageSize: number;
  queryFriendType: number /** 查询好友的类型 1, 直邀 2, 间接 */;
}) {
  return request<API.List<API.FriendsItemProps>>({
    url: "/api/examples/queryFriends",
    method: "POST",
    data,
  });
}

export async function task() {
  return request<API.TaskResponseProps>({
    url: "/api/examples/task",
    method: "POST",
  });
}

export async function goldCoins(data: { current: number; pageSize: number }) {
  return request<API.List<API.ListItemProps>>({
    url: "/api/examples/goldCoins",
    method: "POST",
    data,
  });
}
